
import Cookies from "js-cookie"

const getDefaultState = () => {
    return {
        companyName: Cookies.get('imShowId')?Cookies.get('imShowId'):'',
        companyData:{},
        imShowId:Cookies.get('imShowId')?Cookies.get('imShowId'):'',
        imListId:Cookies.get('imListId')?Cookies.get('imListId'):'',
        useid:Cookies.get('useid')?Cookies.get('useid'):'',
        username:Cookies.get('username')?Cookies.get('username'):'',
        nickname:Cookies.get('nickname')?Cookies.get('nickname'):'',
        mobile:Cookies.get('mobile')?Cookies.get('mobile'):'',
    }
  }

//
// const getDefaultState = () => {
//     return {
//         companyName: Cookies.get('imShowId')?Cookies.get('imShowId'):'SH100277',
//         companyData:{},
//         imShowId:Cookies.get('imShowId')?Cookies.get('imShowId'):'SH100277',
//         imListId:Cookies.get('imListId')?Cookies.get('imListId'):'WA100224',
//         useid:Cookies.get('useid')?Cookies.get('useid'):'5382378',
//         username:Cookies.get('username')?Cookies.get('username'):'Ins_134f520b',
//         nickname:Cookies.get('nickname')?Cookies.get('nickname'):'刘小草',
//     }
// }
  const state = getDefaultState()
  const mutations = {
    SET_COMPANY_DATA: (state, roles) => {
      state.companyData = roles
    },
    SET_COMPANY_BY_USER_INFO:(state, roles)=>{
      // console.log(Cookies.get('imShowId'),'Cookies');
      state.imShowId=Cookies.get('imShowId')
      state.imListId=Cookies.get('imListId')
      state.useid=Cookies.get('useid')
      state.username=Cookies.get('username')
      state.nickname=Cookies.get('nickname')
      state.mobile=Cookies.get('mobile')
    }
  }

  const actions = {
    // dynamically modify permissions
    setCompanyData({ commit }, view) {
      commit('SET_COMPANY_DATA', view)
    },
    setCompanyByUserInfo({commit},view){
      console.log('');
      commit('SET_COMPANY_BY_USER_INFO', view)

    }
  }

  export default {
    state,
    mutations,
    actions
  }
